package SecondeStage.MeiJu;


public class Enumertion02 {
    public static void main(String[] args) {
        System.out.println(Season.summer);
    }

}

// 自定义枚举类
class Season{
    private String name;
    private String decs;

    // 1、 将构造器私有化，防止直接new
    private Season(String decs, String name) {
        this.decs = decs;
        this.name = name;
    }

    // 2、 去掉setXXX方法，防止属性被修改
    public String getName() {
        return name;
    }

    public String getDecs() {
        return decs;
    }

    // 3、 在Seaon内部，直接创建固定的对象
    // 4.  优化，加上final，这样不会在类加载的时候就创建对象
    public static final Season spring =new Season("春天","温暖");
    public static final Season summer =new Season("夏天","炎热");
    public static final Season autumn =new Season("秋天","凉爽");
    public static final Season winter =new Season("冬天","寒冷");

    @Override
    public String toString() {
        return "Season{" +
                "name='" + name + '\'' +
                ", decs='" + decs + '\'' +
                '}';
    }
}